<?php
namespace App\Http\Forms;

use App\Library\OSS;
use App\Modules\Coupon\Models\Coupon;
use Kris\LaravelFormBuilder\Form;

class CouponForm extends Form
{
    public function buildForm()
    {
        $this
            ->add('shop_id', 'select', [
                'label' => "所属门店",
                'rules' => 'nullable|integer',
                'choices' => $this->getData('shop')??[],
            ])
//            ->add('type', 'select', [
//                'label' => "类型",
//                'rules' => 'required|string',
//                'choices' => Coupon::$typeShow,
//            ])
            ->add('title', 'text', [
                'label' => "优惠券名称",
                'rules' => 'required|string',
            ])
            ->add('price_limit', 'text', [
                'label' => "价格限制",
                'rules' => 'required|numeric',
            ])
            ->add('money', 'text', [
                'label' => "优惠券金额",
                'rules' => 'required|string',
            ])
            ->add('shelf_life', 'text', [
                'label' => '有效有效天数',
                'rules' => 'required|string',
            ])
            ->add('applicable', 'select', [
                'label' => "使用范围",
                'attr' => ['class' => "form-control select2 search-goods", 'multiple' => "multiple"],
                'rules' => 'nullable|array',
                'choices' => $this->getData('applicable')??[],
            ])
            ->add('share_image', 'image', [
                'label' => "分享封面",
                'rules' => 'required|string',
                'type' => 'share_image',
                'help_block' => [
                    'text' => "建议尺寸260 * 200",
                ]
            ])
//            ->add('link_id', 'linkage', [
//                'label' => "跳转链接",
//                'rules' => 'required|integer',
//                'attr' => ['class' => "form-control select2"],
//                'url' => route('admin.search_shop_good'),
//                'choices' =>  $this->getData('linkId')??[],
//                'power' => "shop_id",
//            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
